/**
 * @author LKQ
 * @date 2022/1/12 9:42
 * @description 动态规划
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {2,1,5,0,4,6};
        solution.increasingTriplet(nums);
    }
    public boolean increasingTriplet(int[] nums) {
        int n = nums.length;
        int[] leftMin = new int[n];
        int[] rightMax = new int[n];
        // nums[i]左边的最小值
        for (int i = 0; i < n; i++) {
            leftMin[i] = i == 0 ? nums[i] : Math.min(leftMin[i-1], nums[i]);
        }
        // nums[i]右边的最大值
        for (int i = n - 1; i >= 0; i--) {
            rightMax[i] = i == n-1 ? nums[i] : Math.max(rightMax[i+1], nums[i]);
        }
        for (int i = 1; i < n-1; i++) {
            if (nums[i] > leftMin[i-1] && nums[i] < rightMax[i+1]) {
                return true;
            }
        }
        return false;
    }
}
